## Cutting a Code Sample

Every Twoslash code sample needs to be a complete TypeScript program realistically, basically it needs to compile. Quite often to make it compiler, there is a bunch of code which isn't relevant to the user. This can be extracted out of the code sample via `// ---cut---` which removes all of the code above it from the output.

#### `---cut---`

Cut works after TypeScript has generated the project and pulled out all the editor information (like identifiers, queries, highlights etc) and then amends all of their offsets and lines to re-fit the smaller output. What your user sees is everything below the `---cut---`.

```ts twoslash
const level: string = "Danger"
// ---cut---
console.log(level)
```

Would only show a single line.

```ts twoslash
// @filename: a.ts
export const helloWorld: string = "Hi"

// @filename: b.ts
// ---cut---
import {helloWorld} from "./a"
console.log(helloWorld)
```

Would only show the last two lines, but to TypeScript it was a program with 2 files and all of the IDE information is hooked up correctly across the files. This is why `// @filename: [file]` is specifically the only Twoslash command which _is not_ removed, because if it's not relevant it can be `---cut---` away.

#### `---cut-after---`

The sibling to `--cut---` which trims anything after the sigil:

```tsx twoslash
const Page = () => (
// ---cut---
<Container>
  <ImportantComponent />
</Container>
// ---cut-after---
)
```

